﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace MvcPresenter.Models.Validators
{
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
	public class PresentationValidatorAttribute : ValidationAttribute
	{
		public override bool IsValid(object value)
		{
			var presentation = value as Presentation;
			if (presentation == null)
				throw new ArgumentException("適用できるのはPresentationだけ！");

			return presentation.Markups.Any();
		}
	}
}